﻿using AgencyManagerSystem.DataFetcher;
using AgencyManagerSystem.Model;
using System.Data;
using System.Text;

namespace AgencyManagerSystem.DataUpdater
{
    public class PicUpdater : BaseUpdater<PicModel>
    {
        public PicUpdater(PicFetcher dtFetcher) : base(dtFetcher) { }
        public bool BulkUpdate(int[] ids,int owner)
        {
            StringBuilder idsStr = new StringBuilder();
            int counter = 0;
            foreach (int id in ids)
            {
                if (counter != 0)
                {
                    idsStr.Append(",");
                    
                }
                counter++;
                idsStr.Append(id);
            }
            string sqlstr = string.Format("UPDATE BAS_PIC SET OWNER = {0} WHERE AUTOID IN ({1})",owner,idsStr);
            IDbTransaction dbTransaction = DBHelper.GetTran();
            int i = dbTransaction.Execute(sqlstr);
            return i == ids.Length;
        }
    }
}

